import generator from './../generator';

const fs = require('fs');

const path = require('path')

const configPath = {
    out: path.resolve(__dirname, `../../../code-app/app/`),
    tem: path.resolve(__dirname, '../../../src/tem/egg/')
}

export default async function start(datas) {
    datas.forEach(data => {
        generator(data, "controller.egg", `controller/${data.tableName}.js`, configPath);
        generator(data, "service.egg", `service/${data.tableName}.js`, configPath);
    });
    generator({ tables: datas }, "route.egg", "router.js", configPath);
}